<?
/*! \brief Base class for the frontend access point.
 * 
 */
class FrontendController extends Zend_Controller_Action
{	
	public $_uri, $_serviceUri;
	
	/*! \brief Executed by Zend_Controller_Action before final dispatch.
	 * 
	 * Sets commonly used variables (e.g., hostname, service request), populate 
	 * the service menu, and fire off Zend_Layout::startMvc.
	 */
	function init()
	{
		// Get current IP/URI and set controller/view access
		$this->_node = "http://" . $_SERVER['SERVER_ADDR'];
		$this->view->host = $this->_node;
			
		// Populate the menu with service query output
		$contents =  file_get_contents($this->_node.'/Service/query');
		$xmlMenu = new XML();
		$xmlMenu->setStringXml($contents);
		$this->view->menu = $xmlMenu->getSimple();
		
		//Get method name
		$this->_action = $this->getRequest()->getActionName();
		
		// Get base service URI and set controller/view access
		if($this->_action && ServiceManager::isService($this->_action))
		{
			$this->_method = "/Service/" . $this->_action;
			$this->view->serviceReq = $this->_method;
		}
		
		//Start composite view layout
		Zend_Layout::startMvc(array(
			'layoutPath' => BASE_DIR.'/application/views/layouts',
		));
		
		//Enable Dojo for view
		Zend_Dojo::enableView($this->view);

		//Go to index first
		$this->indexAction();
	}
}
